<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>编辑员工</title>
  <style>
    /* 与add.html样式一致 */
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      background: url('/images/2.jpg') no-repeat center center fixed;
      background-size: cover;
      font-family: "微软雅黑", sans-serif;
    }
    .main-content {
      margin-left: 200px;
      padding: 20px;
      background-color: rgba(255, 255, 255, 0.5);
      min-height: calc(100vh - 50px);
    }
    .breadcrumb { margin-bottom: 20px; }
    .breadcrumb a { color: #000; text-decoration: none; }
    .form-container {
      background-color: rgba(255, 255, 255, 0.8);
      padding: 20px;
      border-radius: 5px;
      max-width: 600px;
    }
    .form-group { margin-bottom: 15px; }
    .form-group label {
      display: block;
      margin-bottom: 5px;
      font-weight: bold;
    }
    .form-group input, .form-group select, .form-group textarea {
      width: 100%;
      padding: 8px;
      border: 1px solid #ddd;
      border-radius: 4px;
    }
    .error-msg {
      color: #d9534f;
      margin-bottom: 15px;
      padding: 10px;
      background-color: #f2dede;
      border-radius: 4px;
    }
    .btn-group { text-align: right; margin-top: 20px; }
    .btn {
      padding: 8px 15px;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      margin-left: 10px;
    }
    .btn-update { background-color: #337ab7; color: white; }
    .btn-cancel { background-color: #d9534f; color: white; }
  </style>
</head>
<body>
<div th:replace="~{common/common::topbar}"></div>
<div th:replace="~{common/common::sidebar}"></div>

<div class="main-content">
  <div class="breadcrumb">
    <a href="/login.html">系统首页</a> >
    <a href="/employee_info/list">员工信息管理</a> >
    <span class="current-page">编辑员工</span>
  </div>

  <div th:if="${not #strings.isEmpty(errorMsg)}" class="error-msg">
    [[${errorMsg}]]
  </div>

  <div class="form-container">
    <h3>编辑员工信息</h3>
    <form th:action="@{/employee_info/update}" th:object="${employee}" method="post">
      <input type="hidden" th:field="*{id}">

      <div class="form-group">
        <label for="employeeName">员工姓名</label>
        <input type="text" id="employeeName" th:field="*{employeeName}" required>
      </div>

      <div class="form-group">
        <label for="position">职位</label>
        <input type="text" id="position" th:field="*{position}" required>
      </div>

      <div class="form-group">
        <label for="hireDate">入职日期</label>
        <input type="date" id="hireDate" th:field="*{hireDate}"
               th:value="${#dates.format(employee.hireDate, 'yyyy-MM-dd')}" required>
      </div>

      <div class="form-group">
        <label for="workStatus">工作状态</label>
        <select id="workStatus" th:field="*{workStatus}">
          <option value="1">在职</option>
          <option value="0">离职</option>
        </select>
      </div>

      <div class="form-group">
        <label for="permission">权限级别</label>
        <select id="permission" th:field="*{permission}">
          <option value="1">普通员工</option>
          <option value="2">管理员</option>
        </select>
      </div>

      <div class="form-group">
        <label for="attendanceRecords">考勤记录（JSON格式）</label>
        <textarea id="attendanceRecords" th:field="*{attendanceRecords}" rows="3"></textarea>
      </div>

      <div class="btn-group">
        <a href="/employee_info/list" class="btn btn-cancel">取消</a>
        <button type="submit" class="btn btn-update">更新</button>
      </div>
    </form>
  </div>
</div>
</body>
</html>